#define  _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> singleNumber(vector<int>& nums) {
        int ret = 0;
        for (int i = 0; i < nums.size(); ++i)
        {
            ret ^= nums[i];
        }

        int pos = 0;
        for (int i = 0; i < 32; ++i)
        {
            if (((ret >> i) & 1) == 1)
            {
                pos = i;
                break;
            }
        }

        int num1 = 0;
        for (int i = 0; i < nums.size(); ++i)
        {
            if (((nums[i] >> pos) & 1) == 1)
            {
                num1 ^= nums[i];
            }
        }
        int num2 = ret ^ num1;

        vector<int> sn;
        sn.push_back(num1);
        sn.push_back(num2);

        return sn;
    }
};